package socket;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

public class Chat extends Thread{

	SocketServidor miServidor;
	SocketCliente miCliente;
	String identificador="desconocido";
	
	public Chat(String id, String dir, int clientPort, int serverPort){
		identificador= id;
		miCliente= new SocketCliente(dir,clientPort);
		miServidor= new SocketServidor(serverPort);
	}
	
	public void run(){
		miServidor.setTitle("Programa " + identificador);
		WindowListener l = new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		};
		miServidor.addWindowListener(l);
		miServidor.pack();
		miServidor.setVisible(true);
		miServidor.listenSocket();
	}
}
